<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<table>

    <tr>
        <td><input type="checkbox"  id="ca" onclick="pitchOn()" /><span class="ss">全选</span></td>

        <td>商品名称</td>
        <td>商品价格</td>
        <td >商品数量</td>
        <td >小计</td>
        <td>操作</td>
    </tr>
    <tr>
        <td><input type="checkbox"name="cars" onclick="calculatAll()"/></td>
        <td>毛衣</td>
        <td>20</td>
        <td class="num">2</td>
        <td class="salary">40</td>
    </tr>
    <tr>
        <td><input type="checkbox"name="cars" onclick="calculatAll()"/></td>
        <td>衬衫</td>
        <td>120</td>
        <td class="num">1</td>
        <td class="salary">120</td>
    </tr>
</table>
<p><input type="button" value="批量删除" onclick="deleteAI()"/></p>
<p><input type="button" value="反选" onclick="fanXuan()"/></p>
</body>

<script>
    function pitchOn(){
        var check=document.getElementsByName("cars");
        var alc=document.getElementById("ca");
        var txt=document.getElementsByClassName("ss");
        var isd = alc.checked;
        if(isd){
            txt[0].innerText="取消全选";
        }else{
            txt[0].innerText="全选";
        }
        for(var i=0;i<check.length;i++){
            check[i].checked=isd;
        }
    }function fanXuan(){
        var cn = document.getElementsByName("cars");

        for (var i = 0; i < cn.length;i++) {
            cn[i].checked=!cn[i].checked;

        }
    }

    function deleteAI() {
        var cn = document.getElementsByName("cars");

        for (var i = 0; i < cn.length;i++) {
            if (cn[i].checked){
                deleteTr(cn[i]);
                i = -1;
            }
        }
    }

    function deleteTr(obj){
        obj.parentNode.parentNode.remove();	//删除上上一级的元素
    }
</script>
</html>